import buttons from '@/components/button/combutton';
import commons from '@/components/common/comcommon';
import effects from '@/components/specialeffects/comeffect';
import styles from '@/components/style/comstyle';

const ICON = "icon";
const BUTTON = "button";
const EFFECT = "effect";
const STYLE = "style";
const COMMON = "common";

const svgList = import.meta.glob('@/assets/svg/*.svg', { query: '?raw', import: 'default', eager: true });

const buttonComList = import.meta.glob('@/components/button/*.vue');
const commonComList = import.meta.glob('@/components/common/*.vue');
const effectComList = import.meta.glob('@/components/specialeffects/*.vue');
const styleComList = import.meta.glob('@/components/style/*.vue');

const iconList = Object.entries(svgList).map(([key, value]) => {
    return {
        btName: value,
        type: ICON,
    }
});

const buttonList = [];
const effectList = [];
const styleList = [];
const componentList = [];

for (const key of Object.keys(buttons)) {
    if (buttonComList[key]) {
        buttonList.push({
            btName: buttons[key],
            type: BUTTON,
            comPath: key,
        });
    }
}

for (const key of Object.keys(commons)) {
    if (commonComList[key]) {
        componentList.push({
            btName: commons[key],
            type: COMMON,
            comPath: key,
        });
    }
}

for (const key of Object.keys(effects)) {
    if (effectComList[key]) {
        effectList.push({
            btName: effects[key],
            type: EFFECT,
            comPath: key,
        });
    }
}

for (const key of Object.keys(styles)) {
    if (styleComList[key]) {
        styleList.push({
            btName: styles[key],
            type: STYLE,
            comPath: key,
        });
    }
}

const CPList = {
    ICON,
    BUTTON,
    EFFECT,
    STYLE,
    COMMON,
    svgList,
    buttonComList,
    commonComList,
    styleComList,
    effectComList,
    iconList,
    buttonList,
    componentList,
    effectList,
    styleList
};
export default CPList